<script setup lang="ts">
/*========================================>( 父传子属性 )<========================================*/
const props = defineProps(['covers', 'activeIndex', 'loading'])
/*========================================>( 子传父属性 )<========================================*/
const emits = defineEmits(['change'])

/*========================================>( 监听方法 )<========================================*/
const handleCoverClick = (index: number, item: any) => {
    if (props.loading) {
        return
    }
    emits('change', index)
}

</script>
<template>
    <div class="component-container selector">
        <div class="title">序列</div>
        <div class="box">
            <div class="cover" v-for="item, index in props.covers" :class="{ active: props.activeIndex === index }"
                @click="handleCoverClick(index, item)">
                <div class="image" v-if="item.url" :style="{ backgroundImage: `url(${item.url})` }"
                    :data-series-id="item.id"></div>
                <div class="image-und" v-else>
                    <svg-icon icon-class="image" width="50" height="50" style="color:#ccc" />
                </div>
                <div class="index-view">{{ index + 1 }}</div>
                <div class="loading-screen" v-if="props.loading&&index===props.activeIndex">
                    <svg-icon icon-class="loading1" width="32" height="32" style="color:#000" />
                </div>
            </div>
            <div class="xh-200"></div>
        </div>
    </div>
</template>
<style lang="scss">
.component-container.selector {
    position: relative;
    height: 100%;
    width: 110px;

    .title {
        width: 100%;
        height: 30px;
        line-height: 30px;
        text-align: center;
        color: #ccc;
        border-bottom: solid 1px #666;
    }

    .box {
        margin-top: 10px;
        width: 100%;
        height: 100%;
        overflow-y: auto;

        .cover {
            position: relative;
            width: 80px;
            height: 80px;
            border: solid 2px #3d3d3d;
            // background-color: #000;
            margin: 5px auto;
            cursor: pointer;

            &:hover {
                border: solid 2px #666;
            }

            &.active {
                border: solid 2px #336666;

                .index-view {
                    background-color: #336666;
                    color: #000;
                    font-weight: bold;
                }
            }

            .index-view {
                position: absolute;
                top: 0;
                left: 0;
                z-index: 1;
                width: 18px;
                height: 18px;
                line-height: 18px;
                background-color: #336666;
                color: #e1e1e1;
                text-align: center;
                font-size: 12px;
            }

            .image-count {
                position: absolute;
                top: 3px;
                right: 4px;
                z-index: 1;
                width: 40px;
                height: 18px;
                color: #999;
                text-align: right;
                font-size: 12px;
            }

            .image {
                width: 100%;
                height: 100%;
                background-position: center;
                background-size: 90% 90%;
                background-repeat: no-repeat;
                background-color: #000;
            }

            .image-und {
                width: 100%;
                height: 100%;
                display: flex;
                justify-content: center;
                align-items: center;
                background-color: #000;
            }

            .loading-screen {
                width: 100%;
                height: 100%;
                position: absolute;
                background-color: rgba(255, 255, 255, 0.5);
                top: 0;
                left: 0;
                z-index: 2;
                display: flex;
                justify-content: center;
                align-items: center;
            }
        }


        &::-webkit-scrollbar {
            width: 3px;
            background-color: #3d3d3d;
        }

        &::-webkit-scrollbar-thumb {
            background-color: #336666;
        }

        direction: rtl;
    }

}
</style>
<style lang="scss" scoped></style>